package com.chushouya.common.constant;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 商品状态(-2创建缓存，-1草稿，0下架，1上架，2平台下架)
 */
public enum ProductStatusEnum implements IEnum<Integer> {
    cache(-2, "创建缓存"),
    draft(-1, "草稿"), // 废弃，现方案保存商品json字符串
    offline(0, "下架"),
    online(1, "上架");

    private Integer value;

    private String desc;

    ProductStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }

    public static String getDesc(Integer value) {
        for (ProductStatusEnum thisEnum : ProductStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }
}
